<template>
	<div class="section1 clearfix" style="background-image:url(static/images/background.jpg)">
		<div class="section1-title"><h2>{{res.marketInfo.marketShortName}}-车辆检测与交易信息<img src="static/images/logo1.svg" style="float:right;height:60px;top:5px;" /></h2></div>
		<div class="section5-li" style="width:40%">
			<sale-info :params="res.getDaySaleInfo"></sale-info>
		</div>
		<div class="section5-li" style="width:27%">
			<sale-rank :params="res.getCarSaleVolumeRank"></sale-rank>
		</div>
		<div class="section5-li" style="width:27%">
			<sale-price :params="res.getPriceRank"></sale-price>
		</div>
		<div class="section5-li" style="width:40%">
			<check-info :params="res.getDayCarFirstDetectInfo"></check-info>
		</div>
		<div class="section5-li" style="width:27%">
			<check-pass :params="res.getCarFirstDetectInfo"></check-pass>
		</div>
		<div class="section5-li" style="width:27%">
			<check-auth :params="res.getCarAuthInfo"></check-auth>
		</div>
	</div>
</template>

<script>
	import saleInfo from './saleInfo'
	import saleRank from './saleRank'
	import salePrice from './salePrice'
	import checkInfo from './checkInfo'
	import checkPass from './checkPass'
	import checkAuth from './checkAuth'
  import func from '@/assets/js/func.js'
	export default {
	  components:{
	    saleInfo,saleRank,salePrice,checkInfo,checkPass,checkAuth
	  },
	  data () {
	    return {
	      res: {
	      	getDaySaleInfo:{},
	        getCarSaleVolumeRank:{},
	        getPriceRank:{},
	        getDayCarFirstDetectInfo:{},
	        getCarFirstDetectInfo:{},
	        getCarAuthInfo:{},
	       	marketInfo:{},
	      },
	      marketId:this.$route.query.marketId || '1',
	    }
	  },
	  created () {
	    this.getAll();

	  },
	  computed: {
	    lastData () {
	      return func.handleDate('yyyy-MM-dd HH:mm:ss', new Date())
	    }
	  },
	  filters: {
	    handleDate (value) {
	      return func.handleDate('MM.dd HH:mm:ss', value)
	    }
	  },
	  methods: {
	    getQueryAll: function* () {
	      // 查询每日销售额统计
	      yield this.$axios.get('/controller/public/tvStatis/getDaySaleInfo',{params:{marketId:this.marketId}})
	      // 查询销售出库量排行
	      yield this.$axios.get('/controller/public/tvStatis/getCarSaleVolumeRank',{params:{marketId:this.marketId,pageSize:5}})
	      // 查询价格排行
	      yield this.$axios.get('/controller/public/tvStatis/getPriceRank',{params:{marketId:this.marketId,pageSize:10}})
	      // 查询每日初检信息
	      yield this.$axios.get('/controller/public/tvStatis/getDayCarFirstDetectInfo',{params:{marketId:this.marketId}})
	      // 查询初检信息
	      yield this.$axios.get('/controller/public/tvStatis/getCarFirstDetectInfo',{params:{marketId:this.marketId}})
	      // 查询认证信息
	      yield this.$axios.get('/controller/public/tvStatis/getCarAuthInfo',{params:{marketId:this.marketId}})
	      // 查询市场信息
           yield this.$axios.get('/controller/getMarketList', {params: {marketId: this.marketId}});

	      // 结束
	      return false
	    },
	    getAll () {
	      let getQueryFn = this.getQueryAll()
	      this.$axios.all([
	        getQueryFn.next()['value'],
	        getQueryFn.next()['value'],
	        getQueryFn.next()['value'],
	        getQueryFn.next()['value'],
	        getQueryFn.next()['value'],
	        getQueryFn.next()['value'],
	        getQueryFn.next()['value']
	      ]).then(this.$axios.spread((prems1,prems2,prems3,prems4,prems5,prems6,prems7) => {
	        [
	          this.res.getDaySaleInfo,
	          this.res.getCarSaleVolumeRank,
	          this.res.getPriceRank,
	          this.res.getDayCarFirstDetectInfo,
	          this.res.getCarFirstDetectInfo,
	          this.res.getCarAuthInfo,
	          this.res.marketInfo,
	        ] = [
	          prems1.data.result,
	          prems2.data.result,
	          prems3.data.result,
	          prems4.data.result,
	          prems5.data.result,
	          prems6.data.result,
	          prems7.data.result[0],
	        ]
	      }));
	      setTimeout(()=>{
		  	this.getAll();
		  },3600000)
	    }
	  }
	}
</script>
